﻿using System;
using System.Runtime.Serialization;

namespace SmartMD.DataModel.Entity
{
    /// <summary>
    /// 用户
    /// </summary>
    [DataContract(Name = "UserEntity")]
    public class UserInfo : BusinessEntity
    {
        //private String id;        
        //private String name;
        private string _role;  //角色
        private bool _isLoged = false; //是否登陆
        private String _password;
        private string _department;  //所属部门
        private DateTime _lastModify; //最后修改
        private string _registerId; 

        public override void setValue(string key, Object value)
        {
            if (value is System.DBNull)
                return;
            switch (key.ToLower())
            {
                case "id":
                    this.Id = (string)value;
                    break;
                case "username":
                    this.Name = (string)value;
                    break;
                case "role":
                    this.Role = (string)value;
                    break;
                case "isloged":
                    this.IsLoged =  (value.ToString().Trim() == "TRUE") ? true : false;
                    break;
                case "pwd":
                    this.Password = (string)value;
                    break;
                case "department":
                    this.Department = (string)value;
                    break;
                case "lastmodify":
                    this.LastModify = (DateTime)value;
                    break;
                case "registerid":
                    this.RegisterId = value.ToString();
                    break;
            }
        }

        public String RegisterId
        {
            get
            {
                return _registerId;
            }
            set
            {
                this._registerId = value;
                this.OnPropertyChanged("RegisterId");
            }
        }

        public String Department
        {
            get
            {
                return _department;
            }
            set
            {
                this._department = value;
                this.OnPropertyChanged("Department");
            }
        }
        public DateTime LastModify
        {
            get
            {
                return _lastModify;
            }
            set
            {
                this._lastModify = value;
                this.OnPropertyChanged("LastModify");
            }
        }
        public String Role
        {
            get
            {
                return _role;
            }
            set
            {
                this._role = value;
                this.OnPropertyChanged("Role");
            }
        }
        public bool IsLoged
        {
            get
            {
                return _isLoged;
            }
            set
            {
                this._isLoged = value;
                this.OnPropertyChanged("IsLoged");
            }
        }
        public String Password
        {
            get
            {
                return _password;
            }
            set
            {
                this._password = value;
                this.OnPropertyChanged("Password");
            }
        }
        /*[DataMember(Name = "name")]
       public String Name
       {
           get
           {
               return name;
           }
           set
           {
               this.name = value;
               this.OnPropertyChanged("Name");
           }
       }*/
    }

}
